import { Readable, Writable, Duplex, Transform } from 'stream'

const readable = Readable({ objectMode: true })
const writable = Writable()


readable.push('abc')
readable.push(null)
readable.on('end', () => process.stdout.write('READ DONE'))

writable._write = function (buf, enc, next) {
  console.log(buf.toString(), enc)
  next()
}
writable.on('finish', () => process.stdout.write('WRITE DONE'))




/**
 * readable.pipe() 
 * 等同于
 * readable.on('data')
 */
readable.pipe(writable)
// writable.write('123')
// writable.end()